package com.bjbn.controller;

import com.alibaba.fastjson.JSONObject;
import com.bjbn.bean.ApiCallParams;
import com.bjbn.bean.ApiResult;
import com.bjbn.service.DataphinService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 商铺管理系统
 */
@RestController
@RequestMapping("/dataphin")
@Slf4j
public class Dataphin4BusiApiController {

    @Autowired
    DataphinService dataphinService;

    /**
     * 店铺信息
     * @param orderByList
     * @param pageStart
     * @param pageSize
     * @return
     */
    @RequestMapping("/data_twin_s_busi_table_lake_store_info")
    public JSONObject ads_evc_ecv_material_df(@RequestParam(required = false, defaultValue = "") String orderByList,
                                             @RequestParam(required = false, defaultValue = "1") Integer pageStart,
                                             @RequestParam(required = false, defaultValue = "20") Integer pageSize) {
        String fields = "store_code,store_name,mapping_area,status,terminal,area,floors,area_type,control_type,zt_yf_cn,contract_status,lease_start_date,lease_end_date,planning_format,property_unit,property_status";
        ApiCallParams apiCallParams = new ApiCallParams();
        apiCallParams.setApiId("10385");
        apiCallParams.setApiType("LIST");
        apiCallParams.setAppKey("200000226");
        apiCallParams.setAppSecret("d43bc101cb3b4add8554f821b568c84c");
        apiCallParams.setApiReturnFields(fields);
        apiCallParams.setListType("LIST");

        apiCallParams.setPageStart(pageStart);
        apiCallParams.setPageSize(pageSize);
        apiCallParams.setOrderByList(orderByList);
        ApiResult apiResult = dataphinService.getDataphinData(apiCallParams);

        if (apiResult.getResultCode() == 200) {
            return JSONObject.parseObject(apiResult.getResultBody());
        } else {
            return JSONObject.parseObject(apiResult.getError());
        }
    }

}
